<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <style>
        body{
            background-image: url("catimg/maomi3.jpg");
            background-size: cover;
            background-repeat: no-repeat;
            text-align: center;
        }
        img{
            width: 300px;
        }
    </style>
</head>
<body>
<div id="app">
    <img src="catimg/regcat.png" alt="">
    <el-card style="width: 500px;height:580px; background-color: rgba(80,153,255,0.3);
     margin: 0 auto;border:0" >
        <div slot="header" style=" font-size: 35px;color: #f09117; margin: 0">
                      <span>欢迎注册街巷的猫</span>
            <el-form label-width="40px" style="width: 400px;margin: 20px auto;
        color:black;font-weight:bold">
                <el-form-item label="账号" >
                    <el-input type="text" v-model="user.username" placeholder="请输入账号"></el-input>
                </el-form-item>
                <el-form-item label="密码">
                    <el-input type="password" v-model="user.password" placeholder="请输入密码"></el-input>
                </el-form-item>
                <el-form-item label="昵称" >
                    <el-input type="text" v-model="user.nickname" placeholder="请输入昵称"></el-input>
                </el-form-item>
                <el-form-item label="年龄" >
                    <el-input type="text" v-model="user.age" placeholder="请输入年龄"></el-input>
                </el-form-item>
                <el-form-item label="性别" style="text-align: left">
                    <el-select v-model="user.gender" placeholder="请选择性别"  >
                        <el-option label="男" value="man"></el-option>
                        <el-option label="女" value="wmen"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="邮箱" >
                    <el-input type="text" v-model="user.email" placeholder="请输入邮箱"></el-input>
                </el-form-item>
                <el-form-item label="电话" >
                    <el-input type="text" v-model="user.phone" placeholder="请输入电话"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button style="position: relative;left: -30px" type="primary" @click="reg()">注册</el-button>
                </el-form-item>
            </el-form>
        </div>
    </el-card>
</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                user:{username:"",password:"",nickname:"",age:"",gender:"",email:"",phone:"" }
            }
        },
        methods: {
            reg() {//发出axios注册请求
                console.log(v.user)
                axios.post("/reg", v.user).then(function (response) {
                    if (response.data == 1) {
                        alert("注册成功!");
                        location.href = "/";
                    } else {
                        alert("用户名已存在!");
                    }
                })
            }
        }
    })
</script>
</html>